package com.hh.bss.common;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import org.springframework.jdbc.core.RowMapper;

public class MapObjectRowMapper implements RowMapper {

	public Object mapRow(ResultSet rs, int row) throws SQLException{
		ResultSetMetaData rsmd = rs.getMetaData();
		int columnCount = rsmd.getColumnCount();
		Map results = new LinkedHashMap();		
		for (int i = 1; i <= columnCount; i++){
			String name = rsmd.getColumnName(i);
			results.put(name, rs.getObject(i));			
		}
		return results;
	}
}
